<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>Treeview - Ace Admin</title>

		<meta name="description" content="with selectable items(single &amp; multiple) and custom icons" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/font-awesome.min.css" />

		<!-- page specific plugin styles -->

		<!-- text fonts -->
		<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace-fonts.css" />

		<!-- ace styles -->
		<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace.min.css" id="main-ace-style" />

		<!--[if lte IE 9]>
			<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace-part2.min.css" />
		<![endif]-->
		<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace-rtl.min.css" />

		<!--[if lte IE 9]>
		  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->
		<script src="${pageContext.request.contextPath}/static/assets/js/ace-extra.min.js"></script>

		<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

		<!--[if lte IE 8]>
		<script src="${pageContext.request.contextPath}/static/assets/js/html5shiv.min.js"></script>
		<script src="${pageContext.request.contextPath}/static/assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body>
		<div class="main-content" > 
		</br>
			<table id="sample-table-1"
				class="table table-striped table-bordered table-hover">
				<thead>							
					<tr>
						<td colspan="11">
							<button type="button" class="btn btn-primary add-test">
							<span class="glyphicon glyphicon-user"></span> 
							<spring:message code="page.index.add" />
							</button>
							</td>
								</tr>
								<tr>
									<th>科目编号</th>
									<th>科目名</th>
									<th>科目描述</th>
									<th>科目题数</th>
									<th>总时长</th>
									<th>满分总分</th>
									<th>是否开启考试</th>
									<th>得分</th>
									<th class="hidden-480"><spring:message
											code="user.action.message" /></th>
								</tr>
					</thead>
					<tbody>
						<c:forEach items="${score.dates}" var="score">
							<tr>
								<td>${score.subject.subId }</td>
								<td>${score.subject.name }</td>
								<td>${score.subject.description }</td>
								<td>${score.subject.testCount }</td>
								<td>${score.subject.totalTime }</td>
								<td>${score.subject.totalScore }</td>
								<td>
									<c:choose>
										<c:when test="${score.subject.status == 1}">
											<label class=""></label>
										<span class="label label-success arrowed-in arrowed-in-right">以开启</span>
										</c:when>
										<c:otherwise>
											<label class="label arrowed">已关闭</label>
											<span class="lbl"></span>
										</c:otherwise>		
									</c:choose>
								</td>
								<td><c:choose>
										<c:when test="${empty  score.score.score}">
										没有成绩
										</c:when>
											<c:otherwise>
											${score.score.score}
											</c:otherwise>
									</c:choose>
								</td>
								<td>
									<c:if test="${empty score.score.score }">
									<c:choose>
										<c:when test="${score.subject.status==1}">
										<form action="joinTest" method="post">
											<input type="hidden" name="hiddenSubId" id="hiddenSubId" value="${score.subject.subId}" />
											<input type="hidden" name="hiddenScoreId" id="hiddenScoreId" value="${score.score.id}" />
											<button class="btn btn-primary btn-sm  joinSubject">
												<i class="ace-icon fa fa-pencil bigger-130"></i>参加考试
											</button>
										</form>
										</c:when>
										<c:otherwise>
											<button class="btn btn-primary btn-sm joinSubject" disabled="disabled">
												<i class="ace-icon fa fa-pencil bigger-130"></i>参加考试
											</button>
										</c:otherwise>
									</c:choose>
									</c:if>
									<c:if test="${not empty score.score.score }">
										<button type="button" class="btn btn-primary btn-sm showScoreBtn">
										<i class="glyphicon glyphicon-list-alt"></i>查成绩单
										</button>
									</c:if>
								</td>
									</tr>
							</c:forEach>			
										</tbody>
											<tfoot>
											<tr><td colspan="11">
												<jsp:include page="page.jsp">
												<jsp:param name="url" value="${pageContext.request.contextPath}/score"/>  
												<jsp:param name="items" value="${score.totalSize}"/> 
												<jsp:param name="pageSize" value="${score.pageSize}"/>  
												</jsp:include>
												</td>
											</tr>
										</tfoot>
									</table>
			</div><!-- /.main-content -->
			
			<!-- 显示成绩-模态框(model) -->
		<div class="modal fade" id="showScoreModal" tabindex="-1"
		role="dialog" aria-labelledby="showScoreModelLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">&times;
						</button>
						<h4 class="modal-title" id="showScoreModealLabel">
							查看科目成绩
						</h4>
						<label id="modalSubjectName"></label>
					</div>
					<div class="modal-body">
						<p><label>用户名：</label><label id="userName"></label></p>
						<p><label>科目名：</label><label id="subjectName"></label></p>
						<p><label>考试时间：</label><label id="examTime"></label></p>
						<p><label>得分：</label><label id="score"></label></p>
					</div>
					<div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						<button id="scorePrint" type="button" class="btn btn-primary">
							打印
						</button>
					</div>
			</div>
			<!-- /.modal-content -->
		</div>
</div>			
						
		<script type="text/javascript">
			$('.showScoreBtn').click(function(){
				var subjectId = $(this).parent().siblings().eq(0).text();
				$.ajax({
					type: 'POST',
					url: '${contextPath}/OnlineExam/showScore',
					data: {
						subjectId: subjectId
					},
					dataType : "json",
					success: function(data){
						$('#userName').text(data.scoreNew.userId.userName); 
						$('#subjectName').text(data.scoreNew.subjectId.name);
						$('#examTime').text(data.scoreNew.examTime);
						$('#score').text(data.scoreNew.score);
						$('#showScoreModal').modal('show');					
					}
				});
			});
			
			//试用贴Jqprint打印modal框内的内容
			$('#scorePrint').click(function(){
				$('#showScoreModal .modal-body').jqprint();
			});
		</script>			
		
	</body>
</html>
